package second.codeTop.package1;

import util.ListNode;

/**
 * @ClassName LC160
 * @description:
 * @author: 荣燊
 * @create: 2022-03-29 10:35
 **/
public class LC160 {
    public static void main(String[] args) {
        System.out.println(null != null);
    }

    // 快慢指针
    public static ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        ListNode slow = headA;
        ListNode quick = headB;
        // 若没有相交节点，总会同时到达null
        while (slow != quick) {
            if (slow == null) {
                slow = headB;
            } else {
                slow = slow.next;
            }
            if (quick == null) {
                quick = headA;
            } else {
                quick = quick.next;
            }
        }
        return slow;
    }
}
